package com.note.chh.notebook.Adapter;

import android.app.Activity;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.note.chh.notebook.Model.VideoColletionModel;
import com.note.chh.notebook.R;

import chuangyuan.ycj.videolibrary.video.ManualPlayer;
import chuangyuan.ycj.videolibrary.widget.VideoPlayerView;

/**
 * Created by caihuahui on 2018/3/23.
 */

public class VideoColletionAdapter extends BaseQuickAdapter<VideoColletionModel.DataBean,BaseViewHolder> {
    public VideoColletionAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder helper, VideoColletionModel.DataBean item) {


        VideoPlayerView player = (VideoPlayerView) helper.getView(R.id.exo_play_context_id);

        //列表播放，只能使用ManualPlayer,在你的VideoHolder
        ManualPlayer myPlayer = new ManualPlayer((Activity) mContext, player);
        //设置列表item播放当前视频播放进度.不然不会保存视频播放进度
//        myPlayer.setTag(helper.getAdapterPosition());
        myPlayer.setPlayUri(item.getVideouri());
        myPlayer.setTitle(item.getText());
        player.setTag(helper.getAdapterPosition());
        ImageView previewImage = player.getPreviewImage();
        previewImage.setScaleType(ImageView.ScaleType.CENTER_CROP);
        Glide.with(mContext).load(item.getImage0()).into(previewImage);




    }
}
